// import Home from '@/pages/Home'
const Home = ()=> import('@/pages/Home')

// import Login from '@/pages/Login'
const Login = ()=> import('@/pages/Login')

// import Search from '@/pages/Search'
const Search = ()=> import('@/pages/Search')

// import Register from '@/pages/Register'
const Register = ()=> import('@/pages/Register')

// 商品详情页
// import Detail from '@/pages/Detail'
// 路由懒加载
const Detail = ()=> import('@/pages/Detail')
// 添加商品成功页面
// import AddGood from '@/pages/AddGood'
const AddGood = ()=> import('@/pages/AddGood')

// 购物车
// import Cart from '@/pages/Cart'
const Cart = ()=> import('@/pages/Cart')

// 结算页面
// import Trade from '@/pages/Trade'
const Trade = ()=> import('@/pages/Trade')

// 支付页面
// import Pay from '@/pages/Pay'
const Pay = ()=> import('@/pages/Pay')

// 支付成功页面
// import PaySuccess from '@/pages/PaySuccess'
const PaySuccess = ()=> import('@/pages/PaySuccess')

// 订单中心页面
// import Center from '@/pages/Center'
const Center = ()=> import('@/pages/Center')

// 我的订单页面(订单中心的二级路由)
// import MyOrder from '@/pages/Center/MyOrder'
const MyOrder = ()=> import('@/pages/Center/MyOrder') 

// 团购订单页面(订单中心的二级路由)
// import GroupBuy from '@/pages/Center/GroupBuy'
const GroupBuy = ()=> import('@/pages/Center/GroupBuy')

// 小知识点总结
const EventTest = ()=>import('@/pages/test/event/EventTest')
const VModel = ()=>import('@/pages/test/v-model/Father')
const Sync = ()=>import('@/pages/test/sync/Father')
const AttrsAndListeners = ()=>import('@/pages/test/attrsAndListeners')
const ChildrenAndParent = ()=>import('@/pages/test/childrenAndParent/Father')
const SlotScope = ()=>import('@/pages/test/slotScope/SlotScope')
// 路由配置信息
export default [
    // 小知识点总结
    {path:'/test/event',component:EventTest},
    {path:'/test/v-model',component:VModel},
    {path:'/test/sync',component:Sync},
    {path:'/test/attrsAndListeners',component:AttrsAndListeners},
    {path:'/test/childrenAndParent',component:ChildrenAndParent},
    {path:'/test/slotScope',component:SlotScope},
    // 路由重定向
    { path: '/', redirect: '/home' },
    { path: '/home', component: Home, meta: { showFooter: true } },
    { path: '/login', component: Login },
    {path: '/search/:keyword?',name: 'search',component: Search,meta: { showFooter: true }},
    { path: '/register', component: Register },
    { path: '/detail/:goodId', component: Detail, meta: { showFooter: true } },
    { path: '/addGood', name: 'addGood', component: AddGood, meta: { showFooter: true } },
    { path: '/cart', component: Cart, meta: { showFooter: true } },
    { 
        path: '/trade', 
        component: Trade, 
        meta: { showFooter: true },
        // 登录之后，必须从cart才能进入trade
        beforeEnter: (to, from, next) => {
            if(from.path==='/cart'){
                next()
            }else{
                next(from.path)
            }
        }
    },
    { 
        path: '/pay', 
        component: Pay, 
        meta: { showFooter: true },
        // 登录之后，必须从trade才能进入pay
        beforeEnter: (to, from, next) => {
            if(from.path==='/trade') next()
            else next(from.path)
        }
    },
    { 
        path: '/paySuccess', 
        component: PaySuccess, 
        meta: { showFooter: true }, 
        // 登录之后，必须从pay才能进入paySuccess
        beforeEnter: (to, from, next) => {
            if(from.path==='/pay') next()
            else next(from.path)
        }
    },
    { 
        path: '/center', 
        component: Center, 
        meta: { showFooter: true },
        // 路由重定向
        redirect:'/center/myOrder',
        children:[
            {path:'myOrder',component:MyOrder,meta:{}},
            {path:'groupBuy',component:GroupBuy},
        ]
    }
]